import { defineStore } from 'pinia'
import {login,TestLogin} from "@/api/Login/index.ts"
import storage from "@/utils/storage"
 
export const loginStore  = defineStore('login', {
  state: () => {
    return {
      user:{
		  username:"",
		  password:""
	  }
    }
  },
 
  getters: {
	  
  },
  actions: {
	LOGIN(){
		TestLogin({username:this.user.username,password:this.user.password}).then(res=>{
			  console.log(112,res);
			   if(res.code===200 || res.message==="登陆成功"){
					storage.set("user_token",res.data.token);
					uni.navigateTo({
						url:"/pages/index/index"
					})
			   }
		  })
		// login({username:this.user.username,password:this.user.password}).then(res=>{
		// 	console.log(res);
		// 	if(res.code===200 || res.message==="登陆成功"){
		// 		storage.set("user_token",res.data.user_token);
		// 		uni.navigateTo({
		// 			url:"/pages/index/index"
		// 		})
		// 	}
		// })
	}
  }
})
